import { request } from './request';

/**
 * 获取最新一条血氧数据
 * @param patientUid 患者ID
 */
export function getLatestBloodOxygen(patientUid: string) {
  return request({
    url: `/patient/blood-oxygen/latest/${patientUid}`,
    method: 'GET'
  });
}

/**
 * 分页查询血氧数据
 * @param patientUid 患者ID
 * @param params 分页参数 { pageNum, pageSize }
 */
export function getBloodOxygenPage(patientUid: string, params: { pageNum: number; pageSize: number }) {
  return request({
    url: `/patient/blood-oxygen/page/${patientUid}`,
    method: 'GET',
    data: params
  });
}

/**
 * 按日期查询血氧数据
 * @param patientUid 患者ID
 * @param params 查询参数 { date: string }
 */
export function getBloodOxygenByDate(patientUid: string, params: { date: string }) {
  return request({
    url: `/patient/blood-oxygen/by-date/${patientUid}`,
    method: 'GET',
    data: params
  });
}

/**
 * 查询所有血氧数据
 * @param patientUid 患者ID
 */
export function getAllBloodOxygen(patientUid: string) {
  return request({
    url: `/patient/blood-oxygen/all/${patientUid}`,
    method: 'GET'
  });
}

/**
 * 统计血氧记录数量
 * @param patientUid 患者ID
 * @param date 日期 (YYYY-MM-DD 格式)
 */
export function getBloodOxygenCount(patientUid: string, date: string) {
  return request({
    url: `/patient/blood-oxygen/count/${patientUid}`,
    method: 'GET',
    data: { date }
  });
}

/**
 * 计算平均血氧值
 * @param patientUid 患者ID
 */
export function getAvgBloodOxygen(patientUid: string) {
  return request({
    url: `/patient/blood-oxygen/avg/${patientUid}`,
    method: 'GET'
  });
}
